<template>
  <!-- 党建动态 -->
  <div class="article-list">
    <vue-waterfall-easy
      ref="waterfall"
      :mobileGap="10"
      srcKey="image"
      :imgsArr="list"
      @scrollReachBottom="getData"
    >
      <router-link :to="`/news/detail?id=${props.value.id}`" class="img-info" slot-scope="props">
        <p class="some-info">{{props.value.title}}</p>
        <div class="user">
          <img class="headimg" src="../../../assets/img/study/item.png" alt srcset>
          <span>叶明珠</span>
          <span class="time">3分钟前</span>
        </div>
      </router-link>
      <div slot="waterfall-over"></div>
    </vue-waterfall-easy>
    <!-- <van-pull-refresh v-model="isLoading" @refresh="onRefresh"> -->
    <!-- <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad"> -->
    <!-- <div v-if="list.length==0" class="list-nodate">暂无数据</div> -->
    <!-- <article-cell v-else v-for="item in list" :key="item.id" :data="item"></article-cell> -->
    <!-- <div v-else class="list">
          <div class="item" v-for="item in list" :key="item.id" :data="item">
            <img class="img" :src="item.image|imgPath" alt>
            <div class="title">{{item.title}}</div>
            <div class="extra">3分钟前</div>
          </div>
    </div>-->
    <!-- </van-list> -->
    <!-- </van-pull-refresh> -->
  </div>
</template>
<script>
import vueWaterfallEasy from 'vue-waterfall-easy'
import articleCell from '@/components/article-cell'

export default {
  components: {
    vueWaterfallEasy,
    articleCell
  },
  data () {
    return {
      id: 'f3dca92a7c4842d8b2854cab8b28d884', // 党委动态
      page: 1,
      limit: 20,
      isLoading: false,
      loading: false,
      finished: false,
      list: []
    }
  },
  created () {
    this.getData()
  },
  methods: {
    onGoDetail (id) {
      this.$router.push({
        path: 'news/detail',
        query: {
          id
        }
      })
    },
    getData () {
      this.$axios
        .get('/xbkj-dj/web/article/getArticleListByCategoryId', {
          categoryId: this.id,
          page: this.page,
          limit: this.limit
        })
        .then(res => {
          const list = res.page.list.map(item => {
            let value = item.image
            const firstChar = value ? value.substr(0, 1) : ''
            if (firstChar === '/' || firstChar === 'u') {
              value = 'http://39.106.139.151:7676/' + value
            } else {
              value = value || require('@/assets/img/news.png')
            }
            item.image = value
            return item
          })
          this.list = this.list.concat(list)
          this.$refs.waterfall.waterfallOver()
          this.page++
        })
    }
  }
}
</script>
<style lang="less" scoped>
.article-list {
  background-color: #fff;
  height: 100%;
  position: relative;
  .vue-waterfall-easy-container {
    /deep/ .vue-waterfall-easy {
      & a.img-inner-box{
        overflow: hidden;
      }
    }
    .img-box {
      margin: 10px;
    }
    .some-info {
      padding: 5px;
      margin: 0;
    }
    .user {
      display: flex;
      align-items: center;
      color: #ccc;
      .headimg {
        display: inline-block;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        padding: 6px;
      }
      .time {
        position: absolute;
        right: 10px;
        display: inline-block;
        line-height: 30px;
      }
    }
  }
  .list-nodate {
    height: 116px;
    text-align: center;
    line-height: 116px;
    font-size: 14px;
    color: #ccc;
  }
  .list {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    .item {
      flex: 0 0 50%;
      width: 50%;
      border-radius: 6px;
      margin-bottom: 5px;
      .img {
        display: block;
        width: 100%;
      }
    }
  }
}
</style>
